package com.probiz.estore.common.model.customer.base;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

import com.probiz.estore.common.model.customer.Consult;
import com.probiz.estore.common.model.customer.ConsultVote;
import com.probiz.estore.common.model.product.Product;
import com.probiz.estore.common.model.system.AppUser;
import com.probiz.estore.core.model.BaseObject;

/**
 * Consult Base Java Bean, base class for the model, mapped directly to database table
 * 
 * Avoid changing this file if not necessary, will be overwritten. 
 *
 */
public class ConsultTbl extends BaseObject implements Serializable {

    protected Integer consultId;
	protected String customerName;
	protected String subject;
	protected String message;
	protected String remoteIp;
	protected String address;
	protected Integer satisfiedCount;
	protected Integer unsatisfiedCount;
	protected java.util.Date createTime;
	protected java.util.Date updateTime;
	protected Short status;
	protected Integer replyCount;
	protected Integer onShowReplyCount;
	protected Integer sortOrder;
	protected Short isRead;
	protected Consult parent;
	protected Product product;
	protected AppUser customer;
	protected Set<ConsultVote> consultVotes = new HashSet<ConsultVote>();

	/**
	 * Default Empty Constructor for class Consult
	 */
	public ConsultTbl () {
		super();
	}
	
	/**
	 * Default Key Fields Constructor for class Consult
	 */
	public ConsultTbl (
		 Integer in_consultId
        ) {
		this.setConsultId(in_consultId);
    }

	
	
	
	
	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}


	public AppUser getCustomer() {
		return customer;
	}

	public void setCustomer(AppUser customer) {
		this.customer = customer;
	}

	public Set<ConsultVote> getConsultVotes() {
		return consultVotes;
	}

	public void setConsultVotes(Set<ConsultVote> consultVotes) {
		this.consultVotes = consultVotes;
	}

	/**
	 * 	 * @return Integer
     * @hibernate.id column="consultId" type="java.lang.Integer" generator-class="native"
	 */
	public Integer getConsultId() {
		return this.consultId;
	}
	
	/**
	 * Set the consultId
	 */	
	public void setConsultId(Integer aValue) {
		this.consultId = aValue;
	}	

	/**
	 * 	 * @return Integer
	 */
	public Integer getProductId() {
		return this.getProduct()==null?null:this.getProduct().getProductId();
	}
	
	/**
	 * Set the productId
	 */	
	public void setProductId(Integer aValue) {
	    if (aValue==null) {
	    	product = null;
	    } else {
	        product = new Product(aValue);
	        product.setVersion(Integer.valueOf(0));//set a version to cheat hibernate only
	    }
	}	

	/**
	 * 	 * @return Integer
	 */
	public Integer getCustomerId() {
		return this.getCustomer()==null?null:this.getCustomer().getAppuserId();
	}
	
	/**
	 * Set the appuserId
	 */	
	public void setCustomerId(Integer aValue) {
	    if (aValue==null) {
	    	customer = null;
	    } else {
	    	customer = new AppUser(aValue);
	    	customer.setVersion(Integer.valueOf(0));//set a version to cheat hibernate only
	    }
	}	

	/**
	 * 	 * @return String
	 * @hibernate.property column="customerName" type="java.lang.String" length="64" not-null="false" unique="false"
	 */
	public String getCustomerName() {
		return this.customerName;
	}
	
	/**
	 * Set the customerName
	 */	
	public void setCustomerName(String aValue) {
		this.customerName = aValue;
	}	

	/**
	 * 	 * @return String
	 * @hibernate.property column="subject" type="java.lang.String" length="128" not-null="false" unique="false"
	 */
	public String getSubject() {
		return this.subject;
	}
	
	/**
	 * Set the subject
	 */	
	public void setSubject(String aValue) {
		this.subject = aValue;
	}	

	/**
	 * 	 * @return String
	 * @hibernate.property column="message" type="java.lang.String" length="2048" not-null="false" unique="false"
	 */
	public String getMessage() {
		return this.message;
	}
	
	/**
	 * Set the message
	 */	
	public void setMessage(String aValue) {
		this.message = aValue;
	}	

	/**
	 * 	 * @return String
	 * @hibernate.property column="remoteIp" type="java.lang.String" length="32" not-null="false" unique="false"
	 */
	public String getRemoteIp() {
		return this.remoteIp;
	}
	
	/**
	 * Set the remoteIp
	 */	
	public void setRemoteIp(String aValue) {
		this.remoteIp = aValue;
	}	
	

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	/**
	 * 	 * @return Integer
	 * @hibernate.property column="satisfiedCount" type="java.lang.Integer" length="10" not-null="false" unique="false"
	 */
	public Integer getSatisfiedCount() {
		return this.satisfiedCount;
	}
	
	/**
	 * Set the satisfiedCount
	 */	
	public void setSatisfiedCount(Integer aValue) {
		this.satisfiedCount = aValue;
	}	

	/**
	 * 	 * @return Integer
	 * @hibernate.property column="unsatisfiedCount" type="java.lang.Integer" length="10" not-null="false" unique="false"
	 */
	public Integer getUnsatisfiedCount() {
		return this.unsatisfiedCount;
	}
	
	/**
	 * Set the unsatisfiedCount
	 */	
	public void setUnsatisfiedCount(Integer aValue) {
		this.unsatisfiedCount = aValue;
	}	

	/**
	 * 	 * @return java.util.Date
	 * @hibernate.property column="createTime" type="java.util.Date" length="19" not-null="false" unique="false"
	 */
	public java.util.Date getCreateTime() {
		return this.createTime;
	}
	
	/**
	 * Set the createTime
	 */	
	public void setCreateTime(java.util.Date aValue) {
		this.createTime = aValue;
	}	

	/**
	 * 	 * @return java.util.Date
	 * @hibernate.property column="updateTime" type="java.util.Date" length="19" not-null="false" unique="false"
	 */
	public java.util.Date getUpdateTime() {
		return this.updateTime;
	}
	
	/**
	 * Set the updateTime
	 */	
	public void setUpdateTime(java.util.Date aValue) {
		this.updateTime = aValue;
	}	

	/**
	 * 	 * @return Short
	 * @hibernate.property column="status" type="java.lang.Short" length="5" not-null="false" unique="false"
	 */
	public Short getStatus() {
		return this.status;
	}
	
	/**
	 * Set the status
	 */	
	public void setStatus(Short aValue) {
		this.status = aValue;
	}	
	

	public Consult getParent() {
		return parent;
	}

	public void setParent(Consult parent) {
		this.parent = parent;
	}

	/**
	 * 回复的评论id	 * @return Integer
	 */
	public Integer getParentId() {
		return this.getParent()==null?null:this.getParent().getParentId();
	}
	
	/**
	 * Set the parentId
	 */	
	public void setParentId(Integer aValue) {
	    if (aValue==null) {
	    	parent = null;
	    } else {
	    	parent = new Consult(aValue);
	    	parent.setVersion(Integer.valueOf(0));//set a version to cheat hibernate only
	    }
	}	

	/**
	 * 回复数量	 * @return Integer
	 * @hibernate.property column="replyCount" type="java.lang.Integer" length="10" not-null="false" unique="false"
	 */
	public Integer getReplyCount() {
		return this.replyCount;
	}
	
	/**
	 * Set the replyCount
	 */	
	public void setReplyCount(Integer aValue) {
		this.replyCount = aValue;
	}	

	/**
	 * 可见的回复数量	 * @return Integer
	 * @hibernate.property column="onShowReplyCount" type="java.lang.Integer" length="10" not-null="false" unique="false"
	 */
	public Integer getOnShowReplyCount() {
		return this.onShowReplyCount;
	}
	
	/**
	 * Set the onShowReplyCount
	 */	
	public void setOnShowReplyCount(Integer aValue) {
		this.onShowReplyCount = aValue;
	}	

	/**
	 * 排序值，一般值越小，越靠前	 * @return Integer
	 * @hibernate.property column="sortOrder" type="java.lang.Integer" length="10" not-null="false" unique="false"
	 */
	public Integer getSortOrder() {
		return this.sortOrder;
	}
	
	/**
	 * Set the sortOrder
	 */	
	public void setSortOrder(Integer aValue) {
		this.sortOrder = aValue;
	}	

	/**
	 * 是否已阅	 * @return Short
	 * @hibernate.property column="isRead" type="java.lang.Short" length="5" not-null="false" unique="false"
	 */
	public Short getIsRead() {
		return this.isRead;
	}
	
	/**
	 * Set the isRead
	 */	
	public void setIsRead(Short aValue) {
		this.isRead = aValue;
	}	

	/**
	 * @see java.lang.Object#equals(Object)
	 */
	public boolean equals(Object object) {
		if (!(object instanceof ConsultTbl)) {
			return false;
		}
		ConsultTbl rhs = (ConsultTbl) object;
		return new EqualsBuilder()
				.append(this.consultId, rhs.consultId)
								.append(this.customerName, rhs.customerName)
				.append(this.subject, rhs.subject)
				.append(this.message, rhs.message)
				.append(this.remoteIp, rhs.remoteIp)
				.append(this.satisfiedCount, rhs.satisfiedCount)
				.append(this.unsatisfiedCount, rhs.unsatisfiedCount)
				.append(this.createTime, rhs.createTime)
				.append(this.updateTime, rhs.updateTime)
				.append(this.status, rhs.status)
						.append(this.replyCount, rhs.replyCount)
				.append(this.onShowReplyCount, rhs.onShowReplyCount)
				.append(this.sortOrder, rhs.sortOrder)
				.append(this.isRead, rhs.isRead)
				.isEquals();
	}

	/**
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return new HashCodeBuilder(-82280557, -700257973)
				.append(this.consultId) 
								.append(this.customerName) 
				.append(this.subject) 
				.append(this.message) 
				.append(this.remoteIp) 
				.append(this.satisfiedCount) 
				.append(this.unsatisfiedCount) 
				.append(this.createTime) 
				.append(this.updateTime) 
				.append(this.status) 
						.append(this.replyCount) 
				.append(this.onShowReplyCount) 
				.append(this.sortOrder) 
				.append(this.isRead) 
				.toHashCode();
	}

	/**
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return new ToStringBuilder(this)
				.append("consultId", this.consultId) 
								.append("customerName", this.customerName) 
				.append("subject", this.subject) 
				.append("message", this.message) 
				.append("remoteIp", this.remoteIp) 
				.append("satisfiedCount", this.satisfiedCount) 
				.append("unsatisfiedCount", this.unsatisfiedCount) 
				.append("createTime", this.createTime) 
				.append("updateTime", this.updateTime) 
				.append("status", this.status) 
						.append("replyCount", this.replyCount) 
				.append("onShowReplyCount", this.onShowReplyCount) 
				.append("sortOrder", this.sortOrder) 
				.append("isRead", this.isRead) 
				.toString();
	}

	/**
	 * Return the name of the first key column
	 */
	public String getFirstKeyColumnName() {
		return "consultId";
	}
	
	/**
	 * Return the Id (pk) of the entity, must be Integer
	 */
	public Integer getId() {
		return consultId;
	}

}